<?php
require_once(WEBROOT.'/fckeditor/fckeditor.php');
class News_Form_Element_Fck extends Zend_Form_Element_Textarea{
    /**@todo: use a custom decorator instead of overriding render. 
     * You will have to add some kind of prefix path in order to be able to set the decorator property
    */
    
    /**
     * Render form element
     * 
     * @param  Zend_View_Interface $view 
     * @return string
     */
    public function render(Zend_View_Interface $view = null)
    {
        if (null !== $view) {
            $this->setView($view);
        }
        $oFCKeditor = new FCKeditor($this->getName()) ;
        $oFCKeditor->BasePath = BASEURL.'/fckeditor/' ;
        $oFCKeditor->Height = 300;
        $oFCKeditor->Value        = $this->getValue();
        $content = $oFCKeditor->CreateHtml();
        $this->removeDecorator('ViewHelper');
        foreach ($this->getDecorators() as $decorator) {
            $decorator->setElement($this);
            $content = $decorator->render($content);
        }
        return $content;
    }    
}
